#include <iostream>  
#include <bits/stdc++.h>  
using namespace std;  
map<string,string>a; 
int main()
{
	int n,i;
	char order[2],qq[12],password[22];
	cin>>n;
	for(i=0;i<n;i++)
	{
		scanf("%s",order);
		if(order[0]=='N')
		{
			scanf("%s %s",qq,password);
			if(!a[qq].empty()) cout<<"ERROR: Exist"<<endl;
			else{
				a[qq]=password;
				cout<<"New: OK"<<endl;
			}
		}
		else
		{
			scanf("%s %s",qq,password);
			if(a[qq].empty()) cout<<"ERROR: Not Exist"<<endl;
			else{
				if(a[qq]!=password) cout<<"ERROR: Wrong PW"<<endl;
				else cout<<"Login: OK"<<endl;
			}
		}
	}
	return 0;
}
